import torch
import torch.nn as nn



'''
      1         3       1
(1,1)     (1,3)    (3,1)

'''

input=torch.randn(2,3)
target = torch.randn(2,1)

print('input',input,'target',target)

# w1=torch.randn(1,3,requires_grad=True)
# w2=torch.randn(3,1,requires_grad=True)
# print('w1',w1,'\n','w2',w2)


# 正向传播

fc1 = nn.Linear(3,4)
fc2 = nn.Linear(4,1)
cirtern = nn.MSELoss()

print('两个 fc层的 参数----------------------------------------------')
print(fc1.weight)
print(fc1.bias)
print(fc2.weight)
print(fc2.bias)
print('两个 fc层的 参数----------------------------------------------')


out1 = fc1(input)
out2 = fc2(out1)

loss = cirtern(out2,target)
print('loss---------')
print(loss)
loss.backward()


print('out1---------')
print(out1)

print('out2---------')
print(out2)

print('fc1的导数----------------------')
print(fc1.weight.grad)
print(fc1.bias.grad)


print('fc2的导数----------------------')
print(fc2.weight.grad)
print(fc2.bias.grad)

'''



'''

